<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html">
    <body>
        <ui:composition template="../templates/default3.xhtml">        
            <ui:define name="content">
                <h:form id="addProductionBatch" binding="#{productionBatchManagerBean.loadAddProductionBatch}">
                    <p:messages id="error"/>
                    <p:panel header="Production information" >
                        <table width="100%">
                            <tr>
                                <td>
                                    Date:
                                </td>
                                <td>
                                    <p:calendar mindate="#{productionBatchManagerBean.minDate}" disabled="#{productionBatchManagerBean.lock}" value="#{productionBatchManagerBean.date}"  /> 
                                </td>
                            </tr>
                            <tr>
                                <td>Production line </td>
                                <td>
                                    <h:selectOneMenu required="true"  id="selectOneLine" value="#{productionBatchManagerBean.lineNumber}" disabled="#{productionBatchManagerBean.lock}" >
                                        <f:selectItem itemLabel="Select Line" itemValue="0" />
                                        <f:selectItems value="#{productionBatchManagerBean.lineNumbers}" />
                                    </h:selectOneMenu>



                                </td>

                            </tr>
                            <tr>
                                <td>Type </td>
                                <td>
                                    <h:selectOneMenu required="true"  id="selectOneType" value="#{productionBatchManagerBean.type}" >
                                        <f:selectItem  itemLabel="Normal" itemValue="Normal" />
                                        <f:selectItem  itemLabel="Safety stock" itemValue="Safety stock" />
                                        <f:selectItem  itemLabel="Backorder" itemValue="Backorder" />      
                                    </h:selectOneMenu>



                                </td>

                            </tr>
                            <tr>
                                <td>
                                    Quantity
                                </td>
                                <td>
                                    <p:inputText  required="true"  value="#{productionBatchManagerBean.quantity}" ></p:inputText>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    Product:
                                </td>
                                <td>
                                    <h:selectOneMenu id="selectOneProduct" value="#{productionBatchManagerBean.code}">
                                        <f:selectItem itemLabel="Select Product" itemValue="0" />
                                        <f:selectItems value="#{productionBatchManagerBean.products}" var="product" 
                                                       itemLabel="#{product.name}" itemValue="#{product.code}"/>
                                    </h:selectOneMenu>

                                </td>
                            </tr>
                            <tr>
                                <td>Remark</td>
                                <td>

                                    <p:inputTextarea id="remark" label="Remark" 

                                                     style="width:450px;height:75px;" 
                                                     value="#{productionBatchManagerBean.remark}">
                                    </p:inputTextarea>


                                </td>  </tr>
                            <tr>
                                
                                <td colspan="2" align="center"><hr/>
                                    <p:commandButton id="btnAdd" value="Add" actionListener="#{productionBatchManagerBean.add}" ajax="true" update="error " /></td>
                            </tr>



                        </table>
                    </p:panel>
                    <p:panel header="Production Batch" >


                        <p:dataTable id="productionBatches" var="productionBatch" value="#{productionBatchManagerBean.productionBatches}" selectionMode="single" 
                                     selection="#{productionBatchManagerBean.productionBatch}" update ="productionBatches" paginator="true" rows="6"  
                                     paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}" >

                            <p:column  headerText="Product" >  
                                <center><h:outputText value="#{productionBatch.product.name}" /> </center> 
                            </p:column> 

                            <p:column  headerText="Quantity" >  
                                <center><h:outputText value="#{productionBatch.quantity}" /> </center> 
                            </p:column> 
                            <p:column  headerText="Type" >  
                                <center><h:outputText value="#{productionBatch.productionScheduleDay.type}" /> </center> 
                            </p:column> 
                            <p:column  headerText="Remark" >  
                                <center><h:outputText value="#{productionBatch.remark}" /> </center> 
                            </p:column> 


                        </p:dataTable>

                        <br/>
                        <br/>
                        <hr/>
                        <center><p:commandButton id="btnDone" value="Done" actionListener="#{productionBatchManagerBean.done}" ajax="true" update="error " />
                        </center>


                    </p:panel>



                </h:form>
            </ui:define>        
        </ui:composition>
    </body>
</html>
